home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / util / boot / AmyShutDown_sr.lha / ShutDownMain.c < prev    next >
C/C++ Source or Header  |  1997-06-05  |  4KB  |  132 lines

  1. // AmyShutDown
  2. // Copyright © 1997 Infinity Labs Development Organization
  3. // All Rights Reserved
  4. // Version 1.00
  5. // Author: Manolis S. Pappas
  6.  
  7. /* Libraries */
  8. #include <libraries/mui.h>
  9. #include <libraries/gadtools.h> /* for BARLABEL in MenuItem */
  10.  
  11. /* Prototypes */
  12. #include <clib/muimaster_protos.h>
  13. #include <clib/exec_protos.h>
  14. #include <clib/alib_protos.h>
  15. #include <clib/dos_protos.h>
  16.  
  17.  
  18. /*  Pragmas  */
  19. #include <pragmas/muimaster_pragmas.h>
  20. #include <pragmas/exec_pragmas.h>
  21.  
  22. /*  Ansi  */
  23. #include <stdlib.h>
  24. #include <stdio.h>
  25. /* GenCodeC header end */
  26.  
  27. /* Include generated by GenCodeC */
  28. #include "ShutDownGUI.h"
  29.  
  30. extern long __stack=10000;     // enough stack for MUI
  31.  
  32. /* ASL Requester structure -- used for error handling if MUI fails */
  33.  
  34. struct EasyStruct errorReq={
  35.     sizeof(struct EasyStruct),
  36.     0,
  37.     "AmyShutDown",
  38.     "%s",
  39.     "Ok",
  40. };
  41.  
  42. /* Declarations for libraries (inserted by GenCodeC) */
  43. struct Library * IntuitionBase;
  44. struct Library * MUIMasterBase;
  45. struct Library * LocaleBase;
  46.  
  47. /* Init() function */
  48. void init( void )
  49. {
  50.         if (!(IntuitionBase = OpenLibrary("intuition.library",37)))
  51.         {
  52.                 EasyRequest(NULL,&errorReq,0,"Can't open intuition.library");
  53.                 exit(20);
  54.         }
  55.         if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)))
  56.         {
  57.                 EasyRequest(NULL,&errorReq,0,"Can't open muimaster.library\nMake sure you have MUI installed\nand try again!");
  58.                 CloseLibrary(IntuitionBase);
  59.                 exit(20);
  60.         }
  61.         if (!(LocaleBase = OpenLibrary("locale.library",38)))
  62.         {
  63.                 EasyRequest(NULL,&errorReq,0,"Can't open locale.library\nBuilt-in English Strings will be used!");
  64.         }
  65.         OpenAppCatalog(NULL,NULL);
  66. }
  67. /* GenCodeC init() end */
  68.  
  69. /* End() function */
  70. void end( void )
  71. {
  72.         CloseAppCatalog();
  73.         if (LocaleBase)
  74.                 CloseLibrary(LocaleBase);
  75.         CloseLibrary(MUIMasterBase);
  76.         CloseLibrary(IntuitionBase);
  77.         exit(20);
  78. }
  79. /* GenCodeC end() end */
  80.  
  81. /* Main Function inserted by GenCodeC */
  82. int main(int argc,char **argv)
  83. {
  84.         struct ObjApp * App = NULL;     /* Object */
  85.         BOOL    running = TRUE;
  86.         ULONG   signal;
  87.         int     selection=0;
  88.         
  89.         /* Program initialisation : generated by GenCodeC */
  90.         init();
  91.  
  92.         /* Create Object : generated by GenCodeC */
  93.         if (!(App = CreateApp()))
  94.         {
  95.                 EasyRequest(NULL,&errorReq,0,"Can't create MUI application");
  96.                 end();
  97.         }
  98.  
  99.         while (running)
  100.         {
  101.                 switch (DoMethod(App->App,MUIM_Application_Input,&signal))
  102.                 {
  103.                         case MUIV_Application_ReturnID_Quit:
  104.                                 running = FALSE;
  105.                                 break;
  106.  
  107.                         /* Insert your code between the "case" statement and comment "end of case ..." */
  108.                         case OK:
  109.                         
  110.                         // read the active selection button
  111.                         get(App->radOptions,MUIA_Radio_Active,&selection);
  112.                         
  113.                         // decide what we'll do: 0=shutdown, 1=reboot
  114.                         
  115.                         if(selection==0)
  116.                                 Execute("AmyShutDown.ShutDown <NIL: >NIL:",0,0);
  117.                         else
  118.                                 Execute("AmyShutDown.Reboot <NIL: >NIL:",0,0);
  119.                                 
  120.                         break;        
  121.                         
  122.                         /* End computing of IDCMP */
  123.  
  124.                         default:
  125.                         break;
  126.                 }
  127.                 if (running && signal) Wait(signal);
  128.         }
  129.         DisposeApp(App);
  130.         end();
  131. }
  132.